<!--
 * @Author: HeAo
 * @Date: 2021-10-12 17:15:37
 * @LastEditTime: 2021-10-12 17:20:51
 * @LastEditors: HeAo
 * @Description: 
 * @FilePath: \web2103-2105\web2103code\3-2-Vue\day04\9-插件.html
 * 别乱动！
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">

  </div>
  <script>
    // 1.声明插件
    let MyPlugin = {
      install: (Vue, options) => {
        Vue.myStaticFun = () => {
          console.log('this is staticFun');
        }
        Vue.prototype.$myFun = () => {
          console.log('this is myFun');
        }
      }
    }

    // 2.使用插件(插件的使用，一定要在vue实例生成之前)
    Vue.use(MyPlugin)

    let vm = new Vue({
      el: '#app',
      data: {},
      methods: {},
      created() {
        Vue.myStaticFun()  // 调用自定义的静态方法
        this.$myFun()      // 调用自定义的实例方法
      }
    })
  </script>
</body>

</html>